const {DataTypes} = require('sequelize');
const sequelize = require('../index');
const {User} = require("./user");

const Message = sequelize.define('db_messages', {
    id: {
        type: DataTypes.INTEGER,
        primaryKey: true,
        autoIncrement: true
    },
    work_id: {
        type: DataTypes.INTEGER,
        allowNull: false,
        references: {
            model: 'db_works',
            key: 'id',
        },
    },
    user_id: {
        type: DataTypes.INTEGER,
        allowNull: false,
        references: {
            model: 'db_users',
            key: 'id',
        },
    },
    message: {
        type: DataTypes.TEXT,
    },
    timestamp: {
        type: DataTypes.TIME,
    },
    sender_type: {
        type: DataTypes.STRING
    }

}, {
    timestamps: false,
});

module.exports = {Message};
